/*
 *  $Id: LiftUp.cs 939 2009-12-03 13:12:41Z thenn.erannor $
 *	This file is a part of Ragima CCG.
 *	(C) 2008-2009 Ragima development group.
 *
 *	Licensed under the terms of the GNU GPL License version 2.
 *
 */

namespace Ragima.Cards001.Fire.Abilities {
    public class LiftUp: AbilityCard {
        public LiftUp(): base("001_f_a_lift_up") {
            Level = CompleteLevel.ReadyForTest;
            Element = ElementType.Fire;
            AddCondition(new AffectCondition<SoulTrap.SoulTrapBonus>(GetConditionPhrase(), true));
        }

        public override void DoAction(TargetArgs args) {
            SoulTrap.SoulTrapBonus trap = args.Caster.GetAffect<SoulTrap.SoulTrapBonus>();
            if (trap == null) return;
            int health = args.Caster.Health - 2;
            foreach (Creature cr in args.Player.Enemy.GetCreatures())
                if (cr.Health <= health)
                    cr.AddAffect(new LiftUpAffect(trap.Value));
            trap.Remove();
        }

        private class LiftUpAffect: SpellAffect<LiftUp> {
            private int _value;

            public LiftUpAffect(int value): base(true) {
                DefaultDescription = true;
                _value = value;
                Add(new Affects.Fear(value));
            }

            public override string DescriptionText {
                get { return Description.GetText(_value); }
            }

            public override Affect Clone() {
                return new LiftUpAffect(_value);
            }
        }
    }
}
